package com.example.app.components


import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
fun Spacer1() {
    Column(modifier = Modifier
        .size(200.dp)
        ,verticalArrangement = Arrangement.Center
        ,horizontalAlignment = Alignment.Start
    )
     {
        Text(
            text = "row2",
            modifier = Modifier
                .background(Color.Red)
        )
         // 在两个元素中间填充空元素(Modifier.height(10.dp))
         // 也可以不设置具体高度,直接将两个元素之间的空白填满(Modifier.fillMaxHeight()),但会把元素挤出去
         Spacer(modifier = Modifier.fillMaxHeight())
         Text(
             text = "row1",
             modifier = Modifier
                 .background(Color.Green)
         )

     }
}

@Preview(
    showSystemUi = true
)
@Composable
fun SpacerPreview() {
    Spacer1()
}

